package cn.chencq.proxy.timer.service;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cn.chencq.proxy.timer.handler.ProxyHandlerEng;
import cn.chencq.proxy.util.Util;

public class ProxyIPCallable implements Callable<Map<String, Integer>> {
	private static final Logger LOGGER = LoggerFactory.getLogger(ProxyIPCallable.class);

	private String url;
	private String channel;

	public ProxyIPCallable(String url, String channel) {
		this.url = url;
		this.channel = channel;
	}

	@Override
	public Map<String, Integer> call() throws Exception {
		String rid = Util.generateRID();
		LOGGER.info("rid:{},proxyCallable,url:{},channel:{}", rid, url, channel);
		int num = ProxyHandlerEng.getInstance().crawler(rid,url, channel);
		Map<String, Integer> m = new HashMap<String, Integer>();
		m.put(channel, num);
		LOGGER.info("rid:{},proxyCallable,num:{}", rid, num);
		return m;
	}

}
